package com.jiepu.daily.corejava.advanceed.part2.day0726;

import java.util.Scanner;

/**
 * @Description:
 * @author: xinjie.txt
 * @date: 2020/7/27  8:33
 */
public class CalMain1 {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		System.out.println("Input opperator num1 numn2 : ");
		System.out.println("[eg]: add 100 200");

		String line = scanner.nextLine();

		// 把一行内容分割成三部分
		String[] lines = line.split(" ");

		String operator = lines[0];
		// String 转 double
		double number1 = Double.parseDouble(lines[1]);
		double number2 = Double.parseDouble(lines[2]);
		Calculator calculator = new Calculator();

		if ("add".equals(operator)) {
			System.out.println(calculator.add(number1, number2));
		} else if ("dev".equals(operator)) {
			System.out.println(calculator.dev(number1, number2));
		} else if ("mul".equals(operator)) {
			System.out.println(calculator.mul(number1, number2));
		} else if ("sub".equals(operator)) {
			System.out.println(calculator.sub(number1, number2));
		} else if ("pow".equals(operator)) {
			System.out.println(calculator.pow(number1, number2));
		}

	}
}
